<!-- 报告审核单作废 -->
<template>
    <view>
      <u--form
        labelPosition="top"
        :model="form"
        :rules="rules"
        ref="form"
        labelWidth="auto"
        :labelStyle="{
          fontSize: '14px',
          color: '#B2B2B2',
          lineHight: '20px',
        }"
      >
        <view class="basic-style">
          <view class="basic-title basic-border">基础信息</view>
          <u-form-item label="单据编号" prop="billNo" :borderBottom="false" required>
            <u--input disabled placeholder="请输入单据编号" v-model="form.billNo" border="surround"></u--input>
          </u-form-item>
          <u-form-item label="申请时间" prop="createTime" :borderBottom="false" required>
            <u--input
              v-model="form.createTime"
              disabled
              placeholder="请选择时间"
              border="surround"
              suffixIcon="calendar-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
            ></u--input>
          </u-form-item>
          <u-form-item
					label="报告审核单"
					prop="purchaseBillId"
					:borderBottom="false"
					required
				>
					<selectAuditFormListPopup
					  v-model="form.purchaseBillId"
					  style="width: 100%"
					  placeholder="请选择报告审核单"
					  objectField="form.purchaseBillId"
					  border="surround"
						:proDisabled="true"
            @change="changeVal"
            @select="selectData"
					  suffixIcon="arrow-down-fill"
					  :suffixIconStyle="{ color: '#B2B2B2' }"
					  />
				</u-form-item>
          <u-form-item label="申请人" prop="handlerId" :borderBottom="false" required>
            <h-select-person-input
              style="width: 100%"
              disabled
              v-model="form.handlerId"
              placeholder="请选择申请人"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              objectField="form.handlerId"
            ></h-select-person-input>
          </u-form-item>
          <u-form-item label="申请部门" prop="handlerDeptId" :borderBottom="false" required>
            <h-select-depart-input
              disabled
              v-model="form.handlerDeptId"
              :departName="form.handlerDeptIdText"
              placeholder="请选择部门"
              border="surround"
              style="width: 100%"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              :title.sync="form.handlerDeptIdText"
            ></h-select-depart-input>
          </u-form-item>
        </view>
        <view class="basic-style">
          <view class="basic-title basic-border">项目信息</view>
          <u-form-item label="项目名称" prop="projectId" required>
            <h-select-project-input-popup
              :proDisabled="true"
              :projectStatus="'2'"
              disabled
              ref="projectSelect"
              v-model="form.projectId"
              style="width: 100%"
              placeholder="请选择项目名称"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
            ></h-select-project-input-popup>
            <!-- @change="handleProjectIdChange" -->
          </u-form-item>
          <u-form-item label="项目编号" prop="finalNo" :borderBottom="false">
            <u--input v-model="form.finalNo" disabled placeholder="请输入项目编号" border="surround"></u--input>
          </u-form-item>
          <u-form-item label="关联任务" prop="taskId" required :borderBottom="false">
            <h-select-task-file-input-popup
              :projectId="form.projectId"
              v-model="form.taskId"
              class="w-100"
               diabled
              :label="'billNo'"
              disabled
              :placeholder="form.projectId ? '请选择任务' : '请先选择项目'"
              searchPlaceholder="请输入生产团队"
              :isShowAsterisk="false"
               searchName="productTeamText"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              @realChange="handleTaskIdChange"
              :customParams="{
                changeStatus: '!changing',
                distributionType: '!waiting',
              }"
              @select="form.taskDescription = $event.data.taskDescription"
            ></h-select-task-file-input-popup>
          </u-form-item>
          <u-form-item label="业务名称" prop="categoryName" :borderBottom="false">
            <u--input v-model="form.categoryName" disabled placeholder="请输入业务名称" border="surround"></u--input>
          </u-form-item>
          <u-form-item label="项目负责人" prop="projectLeading" :borderBottom="false">
            <h-select-person-input
              style="width: 100%"
              disabled
              v-model="form.projectLeading"
              placeholder="请选择项目负责人"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              objectField="form.projectLeading"
            ></h-select-person-input>
          </u-form-item>
          <u-form-item label="生产团队" prop="productTeam" :borderBottom="false">
            <h-select-team-input
              style="width: 100%"
              disabled
              v-model="form.productTeam"
              objectField="form.productTeam"
              placeholder="请选择生产团队"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              :tdlx="2"
            ></h-select-team-input>
          </u-form-item>
          <u-form-item label="实施部门" prop="executeDepart" :borderBottom="false">
            <h-select-depart-input
              v-model="form.executeDepart"
              :departName="form.executeDepartText"
              placeholder="请选择部门"
              disabled
              border="surround"
              style="width: 100%"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              :title.sync="form.executeDepartText"
              @detail="onExecuteDepartInput"
            ></h-select-depart-input>
          </u-form-item>
          <u-form-item label="资质单位" prop="qualificationUnit" required>
            <h-select-company-input
              style="width: 100%"
              disabled
              v-model="form.qualificationUnit"
              border="surround"
              placeholder="请选择资质单位"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              objectField="form.qualificationUnit"
            ></h-select-company-input>
          </u-form-item>
          <u-form-item label="签订单位" prop="signUnit" :borderBottom="false">
            <h-select-company-input
              disabled
              style="width: 100%"
              v-model="form.signUnit"
              border="surround"
              placeholder="请选择签订单位"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
              objectField="form.signUnit"
            ></h-select-company-input>
          </u-form-item>
          <u-form-item label="项目所在地址" prop="areaCode" :borderBottom="false">
            <h-select-address-input
              disabled
              style="width: 100%"
              v-model="form.areaCode"
              placeholder="请选择项目地址"
              border="surround"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
            ></h-select-address-input>
          </u-form-item>
          <u-form-item label="项目详细地址" prop="projectAddress" :borderBottom="false">
            <u--input v-model="form.projectAddress" disabled placeholder="请输入项目详细地址"></u--input>
          </u-form-item>

          <u-form-item label="任务类型" prop="taskType" required>
            <h-select-input-tag
              class="w-100"
              disabled
              v-model="form.taskType"
              objectField="model.taskType"
              placeholder="请选择任务类型"
              border="surround"
                          suffixIcon="arrow-down-fill"
                          :suffixIconStyle="{ color: '#B2B2B2' }"
              dictName="task_type"
            ></h-select-input-tag>
          </u-form-item>
          <u-form-item label="任务最终成果报告名称(全称)" prop="projectResult" :borderBottom="false" required>
            <u--textarea disabled v-model="form.projectResult" :maxlength="1000" count :confirm-type="null" placeholder="请输入任务最终成果报告名称(全称)"></u--textarea>
          </u-form-item>
          <u-form-item label="备注" prop="remark" :borderBottom="false">
            <u--textarea disabled v-model="form.remark" :maxlength="200" count :confirm-type="null" placeholder="请输入备注"></u--textarea>
          </u-form-item>

          <u-form-item label="项目评审情况" prop="reviewResult" :borderBottom="false">
            <h-dict-select
              style="width: 100%"
              disabled
              v-model="form.reviewResult"
              placeholder="请选择项目评审情况"
              dictName="review_result"
              suffixIcon="arrow-down-fill"
              :suffixIconStyle="{ color: '#B2B2B2' }"
            ></h-dict-select>
          </u-form-item>
          <u-form-item v-if="form.taskType === '1'" label="报告类型" prop="reportType" required>
            <h-select-input-tag
              class="w-100"
              disabled
              v-model="form.reportType"
              objectField="form.reportType"
              placeholder="请选择报告类型"
              border="surround"
                          suffixIcon="arrow-down-fill"
                          :suffixIconStyle="{ color: '#B2B2B2' }"
              dictName="report_audit_report_type"
            ></h-select-input-tag>
          </u-form-item>
 
          <u-form-item label="费用所属团队" prop="feeTeamId">
            <h-select-team-input
              style="width: 100%"
              v-model="form.feeTeamId"
              disabled
              objectField="form.feeTeamId"
              placeholder="请选择费用所属团队"
              border="surround"
              :tdlx="3"
            />
          </u-form-item>
          <u-form-item label="作废说明" prop="invalidRemark" :borderBottom="false" required>
            <u--textarea v-model="form.invalidRemark" :maxlength="500" count :confirm-type="null" placeholder="请输入作废说明"></u--textarea>
          </u-form-item>
        </view>
        <view class="basic-style">
          <view class="basic-title basic-border">一审工程师</view>
          <ErpFirstInstanceEngineerList :firstInstanceEngineer="true" :twoProjectSpecialist="true" :disabled="true" ref="firstInstanceEngineerList" />
          <view>
              <view class="basic-title basic-border">一审文件结果</view>
              <view class="py-1 space-y-1" style="width: 100%">
                <view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
                <!-- <h-upload-file   v-model="form.oneResultFile" :disabled="firstInstanceEngineer" :isIcon="false"></h-upload-file> -->
                <file-list  v-model="form.oneResultFile" :isDelete="false"></file-list>
              </view>
            </view>
            <!-- <u-form-item label="备注" prop="remark" :borderBottom="false">
            <u--textarea :disabled="true" v-model="form.oneRemark" :maxlength="200" placeholder="请输入备注"></u--textarea>
          </u-form-item> -->
          <u-form-item label="备注" prop="oneRemark">
          <!-- #ifdef APP || APP-PLUS -->
          <u--textarea :confirm-type="null" :disabled="true" count v-model="form.oneRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
          <!-- #endif -->
                <!-- #ifdef H5 -->
                <u--textarea confirm-type="done" :disabled="true" v-model="form.oneRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
                <!-- #endif -->
        </u-form-item>
          
        </view>
        <view class="basic-style">
          <view class="basic-title basic-border">二审主持工程师</view>
           <ErpSecondInstancePresidingEngineerForm :oneProjectSpecialist="true" :firstInstanceEngineer="true" :twoProjectSpecialist="true" :disabled="true" ref="SecondInstancePresidingEngineerForm" />
           <view>
              <view class="basic-title basic-border">二审结果文件</view>
              <view class="py-1 space-y-1" style="width: 100%">
                <view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
                <!-- <h-upload-file   v-model="form.twoHostResultFile" :disabled="twoInstanceEngineer" :isIcon="false"></h-upload-file> -->
                <file-list  v-model="form.twoHostResultFile" :isDelete="false"></file-list>
              </view>
            </view>
            <!-- <u-form-item label="备注" prop="remark" :borderBottom="false">
            <u--textarea :disabled="true" v-model="form.twoHostRemark" :maxlength="200" placeholder="请输入备注"></u--textarea>
          </u-form-item> -->
          <u-form-item label="备注" prop="twoHostRemark">
          <!-- #ifdef APP || APP-PLUS -->
          <u--textarea :confirm-type="null" :disabled="true" count v-model="form.twoHostRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
          <!-- #endif -->
                <!-- #ifdef H5 -->
                <u--textarea confirm-type="done" :disabled="true" v-model="form.twoHostRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
                <!-- #endif -->
        </u-form-item>
        </view>
        <view class="basic-style">
          <view class="basic-title basic-border">二审会审工程师</view>
           <!-- <ErpSecondInstanceReviewEngineerForm /> -->
              <!-- <view class="basic-title basic-border pt-1">新增分配任务信息</view> -->
          <view class="space-y-1 py-1">
            <u-button size="small" :disabled="true"  type="primary" @click="handleAddMember">新增</u-button>
          </view>
          <u-collapse v-if="secondAuditReviewEngineers && secondAuditReviewEngineers.length">
            <u-collapse-item title="二审会审工程师" v-for="(item, index) in secondAuditReviewEngineers" :key="index">
              <FirstInstanceEngineerForm :isSignatureFee="true" :remark="true" :disabled="true" :item="item" :index="index"  />
            </u-collapse-item>
          </u-collapse>
          <u-form-item label="备注" prop="taskDescription">
              <!-- #ifdef APP || APP-PLUS -->
              <u--textarea :confirm-type="null" :disabled="true" count v-model="form.twoJointReviewRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
              <!-- #endif -->
                    <!-- #ifdef H5 -->
                    <u--textarea confirm-type="done" :disabled="true" v-model="form.twoJointReviewRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
                    <!-- #endif -->
            </u-form-item>
          <!-- <u-form-item  label="备注" prop="taskDescription">
                    <u--textarea
                      maxlength="500"
                      count
                      :disabled="true"
                      v-model="form.twoJointReviewRemark"
                      placeholder="请输入备注"
                    ></u--textarea>
                  </u-form-item> -->
        </view>
        <view class="basic-style" v-if="form.taskType === '1'">
          <view class="basic-title basic-border">三审工程师</view>
          <view class="space-y-1 py-1">
            <u-button size="small" :disabled="true" type="primary" @click="handleAddMember">新增</u-button>
          </view>
          <u-collapse v-if="thirdAuditEngineers && thirdAuditEngineers.length">
            <u-collapse-item title="三审工程师" v-for="(item, index) in thirdAuditEngineers" :key="index">
              <FirstInstanceEngineerForm  :remark="true" :disabled="true"  :item="item" :index="index" />
            </u-collapse-item>
          </u-collapse>
          <u-form-item label="备注" prop="threeremark">
              <!-- #ifdef APP || APP-PLUS -->
              <u--textarea :confirm-type="null" :disabled="true" count v-model="form.threeRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
          <!-- #endif -->
                <!-- #ifdef H5 -->
                <u--textarea confirm-type="done" :disabled="true" v-model="form.threeRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
                <!-- #endif -->
              </u-form-item>
          <!-- <u-form-item  label="备注" prop="threeremark">
                    <u--textarea
                      maxlength="500"
                      :disabled="true"
                      count
                      v-model="form.threeRemark"
                      placeholder="请输入备注"
                    ></u--textarea>
                  </u-form-item> -->
 
        </view>
        <view class="basic-style" v-if="form.taskType === '1'">
          <view class="basic-title basic-border">专审人员</view>
          <!-- <ErpSecondInstanceReviewEngineerForm /> -->
          <!-- <view class="basic-title basic-border">二审会审工程师</view> -->
              <!-- <view class="basic-title basic-border pt-1">新增分配任务信息</view> -->
         <view class="space-y-1 py-1">
            <u-button size="small" :disabled="true" type="primary" @click="handleAddMember">新增</u-button>
          </view>
          <u-collapse v-if="specialistAuditPersonnel && specialistAuditPersonnel.length">
            <u-collapse-item title="专审人员" v-for="(item, index) in specialistAuditPersonnel" :key="index">
              <FirstInstanceEngineerForm :remark="true" :disabled="true"  :item="item" :index="index" />
            </u-collapse-item>
          </u-collapse>
          <u-form-item label="备注" prop="threeremark">
          <!-- #ifdef APP || APP-PLUS -->
          <u--textarea :confirm-type="null" :disabled="true" count v-model="form.specializedRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
          <!-- #endif -->
                <!-- #ifdef H5 -->
                <u--textarea confirm-type="done" :disabled="true" v-model="form.specializedRemark" placeholder="请输入备注" :maxlength="200"></u--textarea>
                <!-- #endif -->
        </u-form-item>
          <!-- <u-popup mode="bottom" :show="showFormModal">
            <FirstInstanceEngineerModal
              ref="dataForm"
              :estimatedContractAmount="form.estimatedContractAmount"
              :separateContractAmount="form.separateContractAmount"
              :index="index"
              @submit="handleFormSubmit"
              @close="closeFormModal"
              :model="form"
            />
          </u-popup>  -->
  
        </view>
        <view class="basic-style">
          <view class="basic-title basic-border">附件信息</view>
          <view class="py-1 space-y-1" style="width: 100%">
            <view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
            <!-- <h-upload-file v-model="form.file" :isIcon="false"></h-upload-file> -->
            <file-list v-if="form.file" v-model="form.file" :isDelete="false"></file-list>
          </view>
        </view>
  
        <view class="space-x-1 px-1 btn_position">
          <u-button :disabled="isSubmit" type="primary" :plain="true" text="保存" @click="onDraft"></u-button>
          <u-button :disabled="isSubmit" type="primary" text="保存并提交" @click="onSubmit"></u-button>
        </view>
        <view style="height: 100rpx"></view>
        <u-toast ref="uToast"></u-toast>
        <ProcessNodeConfiguration ref="processConfig" isAfterStart="1" isCheck="1" @ok="onOk"></ProcessNodeConfiguration>
      </u--form>
    </view>
  </template>
  
  <script>
  import moment from 'moment'
  import fileList from '@/pages/synergy/components/fileList.vue'
  import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'
  import { add, edit, info, getBillNo } from '@/api/project/erpReportAudit.js'
  import { mapState } from 'vuex'
  // import FormInfo from '@/pages/project/components/TaskFormInfo.vue'
  // import TaskForm from '@/pages/project/components/TaskForm.vue'
  import FirstInstanceEngineerModal from '@/pages/project/components/FirstInstanceEngineerModal.vue'
  
  import FirstInstanceEngineerForm from '@/pages/project/components/FirstInstanceEngineerForm.vue' 
  
  import ErpFirstInstanceEngineerList from '@/pages/project/components/reference/ErpFirstInstanceEngineerList.vue'
  import ErpSecondInstancePresidingEngineerForm from '@/pages/project/components/reference/ErpSecondInstancePresidingEngineerForm.vue'
  import ErpSecondInstanceReviewEngineerForm from '@/pages/project/components/reference/ErpSecondInstanceReviewEngineerForm.vue'
  import ErpThirdReviewEngineerForm from '@/pages/project/components/reference/ErpThirdReviewEngineerForm.vue'
  import ErpSpecializedAuditorsForm from '@/pages/project/components/reference/ErpSpecializedAuditorsForm.vue'
  // import defaultList from '@/pages/synergy/components/defaultList.vue'
  import ProcessNodeConfiguration from '@/components/ProcessNodeConfiguration/ProcessNodeConfiguration.vue' // 流程节点配置人员选择弹窗
  import http from '@/utils/request'
import HSelectProjectInputPopup from '../../hm-components/h-select-project-input-popup/h-select-project-input-popup.vue'
import selectAuditFormListPopup from '../../hm-components/selectAuditFormListPopup/selectAuditFormListPopup.vue'
  export default {
    name:'ErpReportFormInvalidated',
    components: {
      fileList,
      ProcessNodeConfiguration,
      ErpFirstInstanceEngineerList,
      FirstInstanceEngineerForm,
      FirstInstanceEngineerModal,
      // FormInfo,
      // TaskForm,
      ErpSecondInstancePresidingEngineerForm,
      ErpSecondInstanceReviewEngineerForm,
      ErpSpecializedAuditorsForm,
      ErpThirdReviewEngineerForm,
      selectAuditFormListPopup,
        HSelectProjectInputPopup
      // defaultList,
    },
    data() {
      return {
        projectIdBack: null,
        hideFlag: '0',
        index:null,
        showFormModal:false,
        applyAuthPerson:'',
        // 一审工程师
        firstAuditEngineers:{
          deptId:'',
          empId:'',
          teamId:'',
          deductionRatio:''
        },
        formData:[],
        specialistAuditPersonnel:[],
        thirdAuditEngineers:[],
        secondAuditReviewEngineers:[],
        firstInstanceEngineerList:null,
        SecondInstancePresidingEngineerForm:null,
        form: {
          bpmBizTitle: '',
          reportType:'',
          billNo: '',
          threeRemark:'',
          twoJointReviewRemark:'',
          handlerId: '',
          purchaseBillId:'',
          handlerDeptId: '',
          createTime: '',
          projectId: '',
          finalNo: '',
          taskId: '',
          billType:'cancel',
          invalidRemark:'',
          categoryName: '',
          projectLeading: '',
          productTeam: '',
          executeDepart: '',
          qualificationUnit: '',
          signUnit: '',
          areaCode: '',
          projectAddress: '',
          projectResult: '',
          remark: '',
          engineerSecondReview: '',
          engineerThirdReview: '',
          reviewResult: '',
          secondReviewFee: '',
          secondReviewProcess: '',
          thirdReviewFee: '',
          thirdReviewProcess: '',
          feeTeamId: '',
          // feeTeamId_dictText: '',
          industryCategory: '',
          industryCoefficient: '',
          approvalLevel: '',
          approvalCoefficient: '',
          complexity: '',
          complexCoefficient: '',
          file: '',
          engineerSecondReview:'',
          specializedAuditors:'',
          oneCheckUser:'',
          oneResultFile:'',
        oneRemark:'',
        //第二阶段主持审核结果文件
        twoHostResultFile:'',
        twoHostRemark:'',
        specializedRemark:''
          // industryCategory:'',
          // industryCoefficient:'',
          // complexity:'',
        },
        rules: {
          billNo: [{ required: true, message: '请输入单据编号!', trigger: ['blur', 'change'] }],
          handlerDeptId: [{ required: true, message: '请选择申请部门!', trigger: ['blur', 'change'] }],
          handlerId: [{ required: true, message: '请选择申请人!', trigger: ['blur', 'change'] }],
          createTime: [{ required: true, message: '请选择申请时间!', trigger: ['blur', 'change'] }],
  
          projectId: [{ required: true, message: '请选择项目名称!', trigger: ['blur', 'change'] }],
          taskId: [{ required: true, message: '请选择关联任务!', trigger: ['blur', 'change'] }],
          qualificationUnit: [{ required: true, message: '请选择资质单位!', trigger: ['blur', 'change'] }],
          projectResult: [{ required: true, message: '请输入项目成果!', trigger: ['blur', 'change'] }],
          reportType: [{ required: true, message: '请选择报告类型!', trigger: ['blur', 'change'] }],
          invalidRemark: [{ required: true, message: '请输入作废说明!', trigger: ['blur', 'change'] }],
          purchaseBillId: [{ required: true, message: '请选择报告审核单!', trigger: ['blur', 'change'] }],
        },
        initDictOptions,
        dictOptions: {},
        isSubmit: false,
        basicForm: {},
        nodeObj: {},
        tabvalue: '',
        id: '', // 详情id值
        model: {},
        //代码生成后需手动设置流程编码
        flowCode: 'dev_erp_report_audit_001',
        formUrl: '/erp/omc/reportaudit/modules/ErpReportAuditForm',
        formUrlMobile: '/pages/project/ErpReportFormInvalidated',
        beanName: 'ErpReportAuditCancelFlow',
        urlStartProcess: '/api/erpmng/act/process/activiti/startMutilProcessCanBack'
      }
    },
    onLoad({ id }) {
      this.id = id || ''
    },
    onReady() {
      this.$refs.projectSelect.$on('change', (event) => {
        this.handleProjectIdChange(event)
      })
    },
    onUnload() {
      this.$off('change')
    },
    created() {
      if (this.id) {
        this.loadData(this.id)
      } else {
        this.initForm()
        this.initBillNo()
      }
      this.initDictConfig()
    },
    computed: {
      ...mapState(['userInfo']),
    },
    methods: {

      changeVal(val){
         console.log(val,'val----孙康');
      let project = val
      if (project) {
        this.$set(this.form, 'invalidationPurchaseBill', project.billNo) // 作废的单据编号
        // this.$set(this.model, 'purchaseBillId', project.id) // 
        // this.model = {...project }
        // 赋值
        this.projectIdBack = project.projectId
        this.handleProjectIdChange(project) // 项目
        this.handleTaskIdChange(project) // 任务
        this.$set(this.form, 'projectId', project.projectId)
        // this.$set(this.model, 'finalNo', project.finalNo)
        this.$set(this.form, 'taskId', project.taskId)
        this.$set(this.form, 'qualificationUnit', project.qualificationUnit) // 资质单位
        this.$set(this.form, 'projectResult', project.projectResult) // 任务最终成果报告名称(全称)
        this.$set(this.form, 'remark', project.remark) // 
        this.$set(this.form, 'reportType', project.reportType) 
        this.$set(this.form, 'feeTeamId', project.feeTeamId) 
        this.$set(this.form, 'operateTeamId', project.teamName)
        this.$set(this.form, 'reviewResult', project.reviewResult) 
        this.$set(this.form, 'projectApprovalUser', project.projectApprovalUser) 
      }
         
      },

      selectData(data){
        console.log(data,'data-------');
        this.secondAuditReviewEngineers = data.data.secondAuditReviewEngineers || []
        this.thirdAuditEngineers = data.data.thirdAuditEngineers || []
        this.specialistAuditPersonnel = data.data.specialistAuditPersonnel || []
       this.form.engineerSecondReview = data.data.engineerSecondReview
       this.form.specializedAuditors = data.data.specializedAuditors
       this.form.oneCheckUser = data.data.oneCheckUser
       this.form.industryCategory = data.data.industryCategory
       this.form.industryCoefficient = data.data.industryCoefficient
       this.form.complexity = data.data.complexity
       this.form.complexCoefficient = data.data.complexCoefficient
       this.form.approvalCoefficient = data.data.approvalCoefficient
       this.form.approvalLevel = data.data.approvalLevel
       this.form.reportType = data.data.reportType
       this.form.oneResultFile = data.data.oneResultFile
       this.form.oneRemark = data.data.oneRemark === null ? '' : data.data.oneRemark
       this.form.twoHostResultFile = data.data.twoHostResultFile
       this.form.twoHostRemark = data.data.twoHostRemark === null ? '' : data.data.twoHostRemark
       this.form.specializedRemark = data.data.specializedRemark === null ? '' : data.data.specializedRemark
       this.form.file = data.data.file
       this.form.twoJointReviewRemark = data.data.twoJointReviewRemark === null ? '' : data.data.twoJointReviewRemark 
       this.form.threeRemark = data.data.threeRemark === null ? '' : data.data.threeRemark
        
      //  this.$set(this.model, 'industryCategory', project.industryCategory) 
      //   this.$set(this.model, 'industryCoefficient', project.industryCoefficient)  
      //   this.$set(this.model, 'complexity', project.complexity) 
      //   this.$set(this.model, 'complexCoefficient', project.complexCoefficient) 
      //   this.$set(this.model, 'approvalCoefficient', project.approvalCoefficient) 
      //   this.$set(this.model, 'approvalLevel', project.approvalLevel) 

        this.$nextTick(()=>{
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.empId  =  data.data.firstAuditEngineers[0].empId
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.teamId  =  data.data.firstAuditEngineers[0].teamId
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.expectedAuditFee  =  data.data.firstAuditEngineers[0].expectedAuditFee
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.actualAuditFee  =  data.data.firstAuditEngineers[0].actualAuditFee
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.attachment  =  data.data.firstAuditEngineers[0].attachment
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.deductionRatio  =  data.data.firstAuditEngineers[0].deductionRatio
         this.$refs.firstInstanceEngineerList.firstAuditEngineers.remark  =  data.data.firstAuditEngineers[0].remark
         // 二审主持工程师回显
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.empId  =  data.data.secondAuditChairmanEngineers[0].empId
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.teamId  =  data.data.secondAuditChairmanEngineers[0].teamId
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.expectedAuditFee  =  data.data.secondAuditChairmanEngineers[0].expectedAuditFee
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.actualAuditFee  =  data.data.secondAuditChairmanEngineers[0].actualAuditFee
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.deductionRatio  =  data.data.secondAuditChairmanEngineers[0].deductionRatio
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.signatureFee  =  data.data.secondAuditChairmanEngineers[0].signatureFee
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.remark  =  data.data.secondAuditChairmanEngineers[0].remark
         this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers.attachment  =  data.data.secondAuditChairmanEngineers[0].attachment
        })
      },
  
      handleAddMember() {
        this.index = null
        this.showFormModal = true
              this.basicForm = {}
              this.openFormModal()
      },
      
      openFormModal() {
        this.$nextTick(() => {
                  this.$refs.dataForm.basicForm = this.basicForm
              })
      },
      closeFormModalC() {
              this.$refs.dataFormC.reset()
              this.basicFormC = {}
              this.formDataCIndex = null
              this.showFormModalC = false
          },
  
      closeFormModal(){
        this.$refs.dataForm.reset()
        this.basicForm = {}
        this.index = null
              this.showFormModal = false
      },
       
  
      handleRemoveForm(data){
        this.secondAuditReviewEngineers = this.secondAuditReviewEngineers.filter((i) => i !== data)
      },
  
      handleCopyForm([item, index]){
  
      },
  
      handleFormSubmit([data, index]) {
        this.showFormModal = false
  
        // this.showFormModal = false
        if (typeof index === 'number') {
          this.$set(this.secondAuditReviewEngineers, index, { ...data })
          // 当是编辑的时候，查看需分配款项信息中的数据是否有绑定此任务，如果绑定则替换成新数据
          if (this.receivablePaymentList && this.receivablePaymentList.length > 0) {
            this.receivablePaymentList.forEach((item, index) => {
              if (item && item.planTaskVoList && item.planTaskVoList.length > 0) {
                item.planTaskVoList.forEach((item1, ind) => {
                  if (item1.taskId == data.id) {
                    let obj = {
                      ...item1,
                      categoryName: data.categoryName,
                      taskDesc: data.taskDescription,
                      productTeam: data.productTeam,
                      productCompanyId: data.productCompanyId,
                      productTeamName: data.productTeam_dictText
                    }
                    // data.planId = item.planId
                    this.receivablePaymentList[index].planTaskVoList.splice(ind, 1, obj);
                  }
                })
              }
            })
            this.receivablePaymentList.map((value, index) => {
              this.receivablePaymentList[index].taskId_dictText = '' // 首先款项关联任务字段默认为空
              // 遍历planTaskList数组赋值给taskId_dictText
              this.receivablePaymentList[index].taskId_dictText = value.planTaskVoList && value.planTaskVoList.length ? (value.planTaskVoList.map((obj) => { return obj.categoryName }).join(',')) : '';
            })
          }
        } else {
          this.secondAuditReviewEngineers.push(data)
        }
     
      },
  
      handleEditForm([item, index]) {
        this.basicForm = { ...item }
        this.index = index
        this.showFormModal = true
              this.openFormModal()
      },
  
      // 提交流程成功
      onOk() {
        this.$refs.uToast.show({
          message: '提交成功',
          type: 'success',
          complete() {
            if (getCurrentPages().length > 1) {
              uni.navigateBack()
            } else {
              uni.reLaunch({
                url: '/pages/home/home',
              })
            }
          },
        })
      },
      fillOrHide(task, isEdit) {
              if (task && task.taskType && (task.taskType == 1 || task.taskType == 4)) {
                  // 行业类别
                  this.$set(this.form, 'industryCategory', task.industryCategory) // 行业类别
                  // 行业系数
                  this.$set(this.form, 'industryCoefficient', task.industryCoefficient) // 行业系数
                  // 审批类别(环评)
                  this.$set(this.form, 'approvalLevel', task.approvalLevel) // 审批类别
                  // 审批系数
                  this.$set(this.form, 'approvalCoefficient', task.approvalCoefficient) // 审批系数
                  // 复杂程度
                  this.$set(this.form, 'complexity', task.complexity) // 复杂程度
                  // 复杂系数
                  this.$set(this.form, 'complexCoefficient', task.complexCoefficient) // 复杂系数
              } else {
                  // 行业类别
                  this.$set(this.form, 'industryCategory', '') // 行业类别
                  // 行业系数
                  this.$set(this.form, 'industryCoefficient', '') // 行业系数
                  // 审批类别(环评)
                  this.$set(this.form, 'approvalLevel', '') // 审批类别
                  // 审批系数
                  this.$set(this.form, 'approvalCoefficient', '') // 审批系数
                  // 复杂程度
                  this.$set(this.form, 'complexity', '') // 复杂程度
                  // 复杂系数
                  this.$set(this.form, 'complexCoefficient', '') // 复杂系数
              }
              
        // 流程中和从列表页点击编辑进来的不允许修改是否隐藏字段 只允许选择任务弹框修改
        if (!isEdit) {
          // 只要有这些字段 则不隐藏 没有则隐藏
          if (
            !!this.form.industryCategory ||
            !!this.form.industryCoefficient ||
            !!this.form.approvalLevel ||
            !!this.form.approvalCoefficient ||
            !!this.form.complexity ||
            !!this.form.complexCoefficient
          ) {
            this.form.hideFlag = '1'
            this.hideFlag = '1'
          } else {
            this.form.hideFlag = '0'
            this.hideFlag = '0'
          }
        }
      },
      // 选择关联任务
      // handleTaskIdChange({ data: task }) {
      handleTaskIdChange(task) {
        if (task) {
          // 当前projectId
          this.projectIdBack = this.form.projectId
          // 业务名称 categoryName
          this.$set(this.form, 'categoryName', task.categoryName) // 业务分类
                  this.$set(this.form, 'taskType', task.taskType) // 任务类型
          // 项目负责人
          this.$set(this.form, 'projectLeading', task.projectLeading) // 项目负责人
          // 生产团队
          this.$set(this.form, 'productTeam', task.productTeam) // 生产团队
          // 实施部门
          this.$set(this.form, 'executeDepart', task.executeDepart) // 实施部门
          // 带出 带不出隐藏
          this.fillOrHide(task, false)
        } else {
          // 清空
          this.resetTaskFields()
          this.projectIdBack = null
        }
      },
      // 清空数据
      restProjectFields() {
        // 项目编号（档案编号）
        this.$set(this.form, 'finalNo', '')
        // 签订单位
        this.$set(this.form, 'signUnit', '')
        // 项目地址
        this.$set(this.form, 'areaCode', '')
        this.$set(this.form, 'projectAddress', '')
      },
      resetTaskFields() {
        // 业务名称 categoryName
        this.$set(this.form, 'categoryName', '') // 业务分类
        // 项目负责人
        this.$set(this.form, 'projectLeading', '') // 项目负责人
        // 生产团队
        this.$set(this.form, 'productTeam', '') // 生产团队
        // 实施部门
        this.$set(this.form, 'executeDepart', '') // 实施部门
        // 行业类别
        this.$set(this.form, 'industryCategory', '') // 行业类别
        // 行业系数
        this.$set(this.form, 'industryCoefficient', '') // 行业系数
        // 审批类别(环评)
        this.$set(this.form, 'approvalLevel', '') // 审批类别
        // 审批系数
        this.$set(this.form, 'approvalCoefficient', '') // 审批系数
        // 复杂程度
        this.$set(this.form, 'complexity', '') // 复杂程度
        // 复杂系数
        this.$set(this.form, 'complexCoefficient', '') // 复杂系数
      },
      // 选择项目名称
      handleProjectIdChange(data) {
        let project = data
        if (data && project) {
          // 项目编号（档案编号）
          this.$set(this.form, 'finalNo', project.finalNo)
          // 项目名称
          this.$set(this.form, 'projectName', project.projectName)
          // 签订单位
          this.$set(this.form, 'signUnit', project.signUnit)
          // 项目地址
          this.$set(this.form, 'areaCode', project.areaCode)
          this.$set(this.form, 'projectAddress', project.projectAddress)
          // 如果当前项目和任务关联的项目不一样则清空任务
          if (this.projectIdBack !== project.id) {
            this.projectIdBack = null
            this.$set(this.form, 'taskId', '')
            // 清空任务相关字段
            this.resetTaskFields()
          }
        } else {
          // 清空所有
          this.restProjectFields()
          // 清空任务相关字段
          this.resetTaskFields()
          this.projectIdBack = null
          this.$set(this.form, 'taskId', '')
        }
      },
      // ...mapState(['userInfo']),
      // 查询预立项申请详情
      loadData(id) {
        info({ id }).then(async (res) => {
          if (res.success) {
            this.form = { ...res.result }
            this.hideFlag = res.result.hideFlag
          } else {
            this.$refs.uToast.show({
              message: res.message,
              type: 'error',
            })
          }
        })
      },
      // 约束数字输入框
      // onBlur(item, text) {
      //   if (item == undefined || item == null) {
      //     return false
      //   }
      //   var num = Number(item)
      //   if (num <= 0) {
      //     num = 0
      //   }
      //   if (num >= 99999) {
      //     num = 99999
      //   }
      //   this.form[text] = num.toFixed(1)
      // },
      // 获取单据编号
      async initBillNo() {
        const res = await getBillNo({prefix:'ZFBGSHD',
        subSystemCode:'05'})
        this.form.billNo = res.result
      },
  
      // 初始化新增需要的数据
      initForm() {
        this.form.handlerId = this.userInfo.empId //当前登录人
        this.form.handlerDeptId = this.userInfo.deptId //当前登录人部门
        this.form.createTime = moment().format('YYYY-MM-DD HH:mm:ss')
      },
      validateForm() {
         this.$refs.form.validate()
         return this.$refs.firstInstanceEngineerList.validateForm()
      },
      async initDictConfig() {
        initDictOptions('erp_omc_project,project_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'projectId', res.result)
          }
        })
      },
      getCreateTime() {
        let createTime = this.form.createTime
        let date = createTime.substring(0, 10)
        return date.substring(0, 4) + '年' + date.substring(5, 7) + '月' + date.substring(8, 10) + '日'
      },
      setBpmBizTitle() {
        const that = this
        let projectName = filterMultiDictText(that.dictOptions['projectId'], that.form.projectId + '')
        that.form.bpmBizTitle = (projectName ? projectName + ' - ':'') + this.userInfo?.employee?.name + '-' + that.getCreateTime() + '-' + that.form.billNo
      },
      async onSubmit() {
        await this.validateForm()
        if(!this.form.invalidRemark.trim()) return this.$refs.uToast.warning('请输入作废说明')
        if(!this.form.taskId) return this.$refs.uToast.warning('请选择关联任务')
      
        // 一审工程师
      const firstAuditEngineers =  this.$refs.firstInstanceEngineerList.firstAuditEngineers
      console.log(firstAuditEngineers,'firstAuditEngineers');
        // 二审主持工程师
      const secondAuditChairmanEngineers =  this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers
      console.log(firstAuditEngineers,'firstAuditEngineers');
      
        // return
        this.isSubmit = true
        this.setBpmBizTitle()
        try {
          this.loading = true
          var url = ''
          if (this.id) {
            url = edit
          } else {
            url = add
          }
          const response = await url({
            ...this.form,
            firstAuditEngineers:[firstAuditEngineers],
            secondAuditChairmanEngineers:[secondAuditChairmanEngineers],
            secondAuditReviewEngineers:this.secondAuditReviewEngineers,
            thirdAuditEngineers:this.thirdAuditEngineers,
            specialistAuditPersonnel:this.specialistAuditPersonnel
            // details: this.formData,
          })
          if (response.success) {
            var that = this
            this.isSubmit = true
            // 获取流程列表
            if (this.form.id) {
              this.getProcessList(this.form.id)
            } else {
              // 判断添加的时候是否有返回id值
              if (response.result) {
                this.getProcessList(response.result)
              }
            }
            this.$refs.uToast.show({
              message: response.message,
              type: 'default',
              complete() {
                // that.isSubmit = false
              },
            })
          }
        } finally {
          this.loading = false
        }
      },
      // 获取流程列表
      getProcessList(id) {
              http.get('/api/erp/omc/project/erpOmcProjectTask/checkTaskChangeById', { id: this.form.taskId }).then(res => {
                  if (res.success) {
                      this.$refs.processConfig.showPopup = true
                      this.$refs.processConfig.formUrl = this.formUrl
                      this.$refs.processConfig.formUrlMobile = this.formUrlMobile
                      this.$refs.processConfig.flowCode = this.flowCode
                      this.$refs.processConfig.startProcess = this.urlStartProcess
                      this.$refs.processConfig.edit(id, '', this.beanName)
                  } else {
                      this.$refs.uToast.show({
                          message: res.message,
                          complete () {
                              if (getCurrentPages().length > 1) {
                                  uni.navigateBack()
                              } else {
                                  uni.reLaunch({
                                      url: '/pages/home/home'
                                  })
                              }
                              
                          }
                      })
                  }
              })
      },
      async onDraft() {
        // await this.validateForm()
        this.isSubmit = true
        this.setBpmBizTitle()
                // 一审工程师
      const firstAuditEngineers =  this.$refs.firstInstanceEngineerList.firstAuditEngineers
      console.log(firstAuditEngineers,'firstAuditEngineers');
        // 二审主持工程师
      const secondAuditChairmanEngineers =  this.$refs.SecondInstancePresidingEngineerForm.firstAuditEngineers
      console.log(firstAuditEngineers,'firstAuditEngineers');
        try {
          this.loading = true
          var url = ''
          if (this.id) {
            url = edit
          } else {
            url = add
          }
          const response = await url({
            ...this.form,
            firstAuditEngineers:[firstAuditEngineers],
            secondAuditChairmanEngineers:[secondAuditChairmanEngineers],
            secondAuditReviewEngineers:this.secondAuditReviewEngineers,
            thirdAuditEngineers:this.thirdAuditEngineers,
            specialistAuditPersonnel:this.specialistAuditPersonnel
            // details: this.formData,
          })
          if (response.success) {
            this.isSubmit = true
            this.$refs.uToast.show({
              message: response.message,
              type: 'default',
              complete() {
                this.isSubmit = false
                if (getCurrentPages().length > 1) {
                  uni.navigateBack()
                } else {
                  uni.reLaunch({
                    url: '/pages/home/home',
                  })
                }
              },
            })
          }
        } finally {
          this.loading = false
        }
      },
    },
    watch: {
      form: {
        handler(form) {
          console.log('model update', form)
        },
        deep: true,
      },
    },
  }
  </script>
  
  <style lang="scss" scoped>
  @import url('@/assets/inputStyle.scss');
  .trip-form-data {
    ::v-deep {
      .u-form-item__body {
        padding-top: 2px;
        padding-bottom: 2px;
      }
    }
  }
  .checkbox-item {
    display: flex;
    align-items: center;
  }
  </style>
  